package newnes.io.memory;
/**
 * @(#)MappedMemory.java
 *
 *Represents a segment of memory that may be mapped as an I/O port
 *
 * @author DG
 * @version 1.00 2009/3/28
 */
import newnes.io.memory.Memory;

public abstract class MappedMemory extends Memory {
	private Memory[] hooks = new Memory[16];
	private int size = 0;
	
	public MappedMemory(){
		super();	
	}
	
	public MappedMemory(int size){
		super(size);
	}
	
	public void addMemoryHook(Memory memory, AddressSpace address){
		hooks[address.hashCode()] = memory;
	}
	
	public Memory getMemoryHook(int address){
		Memory potential_hook = hooks[address>>12];
		if(potential_hook.getAddressSpace().isInRange(address)){
			return potential_hook;
		}
		return null;
	}
}
